﻿#include <iostream>
using namespace std;

struct BiNode{
	int data;
	BiNode *lChild, *rChild;
};

BiNode * searchBST(BiNode * root, int k){
	if(root == NULL) {
		return NULL;
	} else if(root->data == k){
		return root;
	} else if(k < root->data){
		return searchBST(root->lChild, k);
	} else {
		return searchBST(root->rChild, k);
	}
}

BiNode * insertBST(BiNode *root, int data){
	if(root == NULL){
		root = new BiNode;
		root -> data = data;
		root -> lChild = root-> rChild = NULL;
		
		return root;
	}
	if(data <= root->data){
		root->lChild = insertBST(root->lChild, data);
	} else {
		root -> rChild = insertBST(root->rChild,data);
	}
	
	return root;
}

BiNode *createBST(int a[], int n){
	BiNode *T = NULL;
	for(int i = 0; i < n; i++){
		T = insertBST(T, a[i]);
	}
	
	return T;
}

int main(){
	
	
	system("pause");
	return 0;
}


